# -*- coding: utf-8 -*-
from odoo import models, fields, api
from odoo.exceptions import ValidationError

class EmpCalenderweek(models.Model):
    _name = 'emp.calenderweek'

    autono = fields.Char('人員自動編號')
    depkind = fields.Many2one(string='部別', comodel_name='emp.codedepkind')
    amstart = fields.Char('上班時間點')
    noonstart = fields.Char('午休開始時間')
    pmstart = fields.Char('下班時間點')
    amend = fields.Char('上班刷卡允許時間')
    noonend = fields.Char('午休結束時間')
    pmend = fields.Char('下班刷卡允許時間')
    duty = fields.Char('當天是否上班') #boolean
    memo = fields.Char('備註')
    startdate = fields.Datetime('核准日期')
    leavebasic = fields.Char('請假基準')
    week = fields.Char('星期')
    campus_location = fields.Char()
    work_category = fields.Char()
    category = fields.Char()

    # @api.onchange('depkind_id')
    # def onchange_product_id(self):
    #     variant_ids_list = []
    #     if self._context.get('codedetno'):
    #         depkind_id = self.env["emp.codedepkind"].browse(self._context.get('codedetno'))
    #         for variant_id in depkind_id.calenderweek_ids:
    #             if variant_id == 1:
    #                 variant_ids_list.append(variant_id.id)
    #
    #     return result['domain'] = {'depkind_id': [('id', 'in', variant_ids_list)]
